package com.lc.activiti.sys.controller;



import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.lc.activiti.config.Result;
import com.lc.activiti.sys.entity.SysMessage;
import com.lc.activiti.sys.service.SysMessageService;
import com.lc.activiti.utils.JwtUtil;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import javax.annotation.Resource;
import java.io.Serializable;

/**
 * (SysMessage)表控制层
 *
 * @author 骆超
 * @since 2021-07-07 10:26:08
 */
@RestController
@RequestMapping("sysMessage")
public class SysMessageController {
    /**
     * 服务对象
     */
    @Resource
    private SysMessageService sysMessageService;

    @PostMapping("getMessageData")
    public Result getMessageData(){
        return Result.success(sysMessageService.list(Wrappers.lambdaQuery(SysMessage.class).eq(SysMessage::getRecipient, JwtUtil.getUser().getId()).eq(SysMessage::getReadStatus,0).orderByDesc(SysMessage::getCreateDate)));
    }


    @PostMapping("seenMessage")
    public Result seenMessage(@RequestBody SysMessage sysMessage){
        return sysMessageService.seenMessage(sysMessage);
    }

}
